﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

using Urgencias.Controlador;

namespace Urgencias.Vista
{
    public partial class ListadoPacientesUC : UserControl
    {
        public ListadoPacientesUC()
        {
            InitializeComponent();
        }

        private void ListadoPacientes_Load(object sender, EventArgs e)
        {
            //First, a connection
            //string connectionString = "Data Source=(LocalDB)\\v11.0;AttachDbFileName=|DataDirectory|\\Database.mdf;Connect Timeout=30";
            //SqlConnection connection = new SqlConnection(connectionString);
            //Now, the connection string
            //Conexion.Instance.con = 
            //That's the connection string you copied. As you can see, you have to make some changes with the quotation marks. Watch them carefully.

            using (Conexion.Instance.Con) //With this, you don't have to close the connection
            {
                
                SqlDataAdapter adapter = new SqlDataAdapter("select * from Paciente", Conexion.Instance.Con);
                DataSet ds = new DataSet();
                adapter.Fill(ds, "Paciente");
                GridViewPacientes.DataSource = ds;
                GridViewPacientes.DataMember = "Paciente";
            }
        }
    }
}
